<?php ob_start();?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="renderer" content="webkit" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
    <title><?php echo $output['site_name']?></title>
    <link rel="stylesheet" href="<?php echo TEMPLATE_SITE_URL;?>/zsm-static/_build/p/zhongxin/zhongxin.css">
    <script src="<?php echo TEMPLATE_SITE_URL;?>/zsm-static/_build/c/index.js"></script>
</head>
<body>
<div id="pop" style="display: none;">
    <img src="<?php echo TEMPLATE_SITE_URL;?>/images/poping.png" width="250" height="150">
</div>
<!--    首页小导航-->
<?php $zh_menu='关注'?>
<?php include template('home/zsm/menu');?>
<div class="app saleMain">
</div>
<input type="hidden" name="pagenum" value="1" id="pagenum">
<input type="hidden" name="totalpage" value="<?php echo $output["totalpage"];?>" id="totalpage">
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/zepto.js" charset="utf-8"></script>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/touch.js" charset="utf-8"></script>
<script type="text/javascript">
    $(function(){
        //检测滚动
        $(window).scroll(function () {
            var $body = $("body");
            if (($(window).height() + $(window).scrollTop()) >= $body.height()) {
                var pagenum = parseInt($('#pagenum').val());
                var nextpage = eval(pagenum+1);
                var totalpage = parseInt($('#totalpage').val());
                $('#pagenum').val(nextpage);
                dataajax();
            }
        });
        $('.shauction').click(function(){
            var auction_id = $('input[name=show_id]').val();
            var is_show = $('.showword').attr('is_show');
            $.ajax({
                type:'get',
                url:'index.php?act=my&op=updateshow',
                data:{auction_id:auction_id,is_show:is_show},
                dataType:'json',
                success:function(data){
                    if(data.state == 1){
                        location.reload();
                    }
                }
            });
            return false;
        });
        $('.xiajiapaipin').click(function(){
            var auction_id = $('input[name=xiajia_id]').val();
            var state = '1';
            $.ajax({
                type:'get',
                url:'index.php?act=my&op=updatestate',
                data:{auction_id:auction_id,is_state:state},
                dataType:'json',
                success:function(data){
                    if(data.state == 1){
                        location.reload();
                    }
                }
            });
            return false;
        });
        $('.greyBn').click(function(){
            $('#pop2').hide();
            $('#pop3').hide();
            $('#pop4').hide();
        });
        //页面加载完成后记载关注数据
        function dataajax(){
            var pagenum = $('#pagenum').val();
            var user_id = <?php echo intval($_GET['user_id']);?>;
            var seller_id = <?php echo intval($_GET['seller_id']);?>;
            var auction_id = <?php if(isset($_GET['auction_id'])){ echo $_GET['auction_id'];}else{ echo '0';}?>;
            $.ajax({
                type:'get',
                url:'index.php?act=index&op=auctionajax',
                data:{user_id:user_id,seller_id:seller_id,auction_id:auction_id,pagenum:pagenum},
                dataType:'html',
                beforeSend:function(){
                    $('.loadNextPage').show();
                },
                success:function(html){
                    $('.saleMain').append(html);
                    $('.bidBtngre').click(function(){
                        var auction_id = $(this).attr('bidauction');
                        ajaxauctionprice(auction_id);
                    });
//                    $(".close").click(function(){
//                        $('.fixednumMain').empty();
//                    });
                    //喜欢按钮
                    $('.likeIt').click(function(){
                        var auction_id = $(this).attr('like_auction_id');
                        var res = ajaxlike(auction_id);
                        $(this).removeClass('likeIt');
                        $(this).addClass('liked');
                    });
                    //查看已经下架的
                    $('.xiajia').click(function(){
                        var auction_id = $(this).attr('auction_id');
                        $('input[name=xiajia_id]').val(auction_id);
                        $('#pop3').show();
                    });
                    $('.showauction').click(function(){
                        var auction_id = $(this).attr('auction_id');
                        $('input[name=show_id]').val(auction_id);
                        $('.showword').html('显示');
                        $('.showword').attr('is_show','0');
                        $('#pop4').show();
                    });
                    $('.hideauction').click(function(){
                        var auction_id = $(this).attr('auction_id');
                        $('input[name=show_id]').val(auction_id);
                        $('.showword').html('隐藏');
                        $('.showword').attr('is_show','1');
                        $('#pop4').show();
                    });
                    //关注
                    $('.guanzhu').click(function() {
                        var uid = '<?php echo $_COOKIE['user_id']?>';
                        var fid = $(this).attr('seller_id');
                        $.ajax({
                            type: 'get',
                            url: 'index.php?act=my&op=guanzhu',
                            data: {uid: uid, fid: fid},
                            dataType: 'json',
                            success: function (data) {
                                location.reload();
                            }
                        });
                    });
                    //查看更多
                    $('.logmore').click(function(){
                        var auction_id = $(this).attr('auction_id');
                        $(".loglist"+auction_id).show();
                        $(this).hide();
                    });
                    //查看全文，当文字过多的时候
                    $('.quan').click(function(){
                        var auction_id = $(this).data('auction_id');
                        $('.showdesc'+auction_id).css("overflow","visible");
                        $('.showdesc'+auction_id).height('');
                        $(".quanwen"+auction_id).hide();
                    });
                    //分享
                    $('.fenxiang1').click(function(){
                        $('#pop').show();
                        var auction_id = $(this).attr('auction_id');
                        var title = '【'+$(this).attr('nickname')+'】的<?php echo $output['site_name'];?>开拍喽！';
                        var desc = $(this).attr('auction_description');
                        var link = $(this).attr('auction_link');
                        var imgUrl1 = $(this).attr('imgurl');
                        wx.onMenuShareAppMessage({
                            title: title,
                            desc: desc,
                            link: link,
                            imgUrl: imgUrl1,
                            trigger: function (res) {
                                //alert('用户点击发送给朋友');
                            },
                            success: function (res) {
                                $.ajax({
                                    type:'get',
                                    url:'index.php?act=index&op=share',
                                    data:{auction_id:auction_id},
                                    success:function(){
                                        return false;
                                    }
                                });
                                $('#pop').hide();
                            },
                            cancel: function (res) {
                                $('#pop').hide();
                                //alert('已取消');
                            },
                            fail: function (res) {
                                //alert(JSON.stringify(res));
                            }
                        });
                        wx.onMenuShareTimeline({
                            title: desc,
                            link: link,
                            imgUrl: imgUrl1,
                            success: function () {
                                $.ajax({
                                    type:'get',
                                    url:'index.php?act=index&op=share',
                                    data:{auction_id:auction_id},
                                    success:function(){
                                        return false;
                                    }
                                });
                                $('#pop').hide();
                                // 用户确认分享后执行的回调函数
                            },
                            cancel: function () {
                                $('#pop').hide();
                                // 用户取消分享后执行的回调函数
                            }
                        });
                    });
                    $('.fenxiang').click(function(){
                        $('#pop').show();
                        var auction_id = $(this).attr('auction_id');
                        var title = '【'+$(this).attr('nickname')+'】的<?php echo $output['site_name'];?>开拍喽！';
                        var desc = $(this).attr('auction_description');
                        var link = $(this).attr('auction_link');
                        var imgUrl = $(this).attr('imgurl');
                        wx.onMenuShareAppMessage({
                            title: title,
                            desc: desc,
                            link: link,
                            imgUrl: imgUrl,
                            trigger: function (res) {
                                //alert('用户点击发送给朋友');
                            },
                            success: function (res) {
                                $.ajax({
                                    type:'get',
                                    url:'index.php?act=index&op=share',
                                    data:{auction_id:auction_id},
                                    success:function(){
                                        return false;
                                    }
                                });
                                $('#pop').hide();
                            },
                            cancel: function (res) {
                                $('#pop').hide();
                                //alert('已取消');
                            },
                            fail: function (res) {
                                //alert(JSON.stringify(res));
                            }
                        });
                        wx.onMenuShareTimeline({
                            title: desc,
                            link: link,
                            imgUrl: imgUrl1,
                            success: function () {
                                $.ajax({
                                    type:'get',
                                    url:'index.php?act=index&op=share',
                                    data:{auction_id:auction_id},
                                    success:function(){
                                        return false;
                                    }
                                });
                                $('#pop').hide();
                                // 用户确认分享后执行的回调函数
                            },
                            cancel: function () {
                                $('#pop').hide();
                                // 用户取消分享后执行的回调函数
                            }
                        });
                    });
                },
            });
        }
        //点击喜欢按钮
        function ajaxlike(auction_id){
            var user_id = <?php echo $_COOKIE['user_id'];?>;
            $.ajax({
                type:'get',
                url:'index.php?act=index&op=like',
                data:{user_id:user_id,auction_id:auction_id},
                dataType:'json',
                success:function(data){
                    if(data.state == 1){
                        $('img[like_img_auction_id="'+auction_id+'"]').show();
                        $('div[like_div_auction_id="'+auction_id+'"]').show();
                        var likenum = $('div[like_auction_id="'+auction_id+'"]').html();
                        $('div[like_auction_id="'+auction_id+'"]').html(parseInt(likenum)+1);
                        var html = '<a href="index.php?act=my&op=home&user_id='+data.data.user_id+'" class="likeAvatar" style="background-image: url('+data.data.avatar+')"></a>';
                        $('label[auctionavatar="'+auction_id+'"]').append(html);
                        return true;
                    }else{
                        return false;
                    }
                }
            });
        }
        function ajaxauctionprice(auction_id){
            var user_id = '<?php echo $_COOKIE['user_id']?>';
            var mobile = '<?php echo $output['user']['mobile']?>';
            var isauth = '<?php echo $output['user']['isauth']?>';
            var subscribe = '<?php echo $output['user']['subscribe']?>';
            if(subscribe!='1'){
                $.ajax({
                    type:'get',
                    url:'index.php?act=my&op=popguanzhu',
                    data:{auction_id:auction_id},
                    dataType:'json',
                    success:function(){
                        return false;
                    }
                });
                //提示信息，关注后才可以出价格
                $('#pop2').show();
                return false;
            }
            if(isauth!='1'){
                location.href = 'index.php?act=index&op=mobile&auction_id='+auction_id;
                return false;
            }
            $.ajax({
                type:'get',
                url:'index.php?act=index&op=auctionaddprice',
                data:{auction_id:auction_id,user_id:user_id},
                dataType:'html',
                success:function(html){
                    $('.fixednumMain').empty();
                    $('.fixednumMain').html(html);
                }
            });
            $('.fixednumMain').show();
        }
        dataajax();
    });
</script>
<script type='text/javascript'>
    $(function(){
        var time = parseInt("<?php echo TIMESTAMP;?>");
        $('.process').each(function(){
            var lag = parseInt($(this).attr('endtime')) - time;
            if(lag>0){
                var second = Math.floor(lag % 60);
                var minite = Math.floor((lag / 60) % 60);
                var hour = Math.floor((lag / 3600) % 24);
                var day = Math.floor((lag / 3600) / 24);
                $(this).html('<span style="color:#910012;>&nbsp;'+day+'&nbsp;</span>'+'<?php echo $lang['bearshop_day'];?>'+'<span style="color:#910012;">&nbsp;'+hour+'&nbsp;</span>'+'<?php echo $lang['bearshop_hour'];?>'+'<span style="color:#910012;">&nbsp;'+minite+"&nbsp;</span>"+'<?php echo $lang['bearshop_minute'];?>'+'<span style="color:#910012;">'+second+'</span>');
            }
        });
        function updateEndTime(){
            time++;
            $(".process").each(function(){
                var lag = parseInt($(this).attr('endTime')) - time;
                if(lag>0){
                    var second = Math.floor(lag % 60);
                    var minite = Math.floor((lag / 60) % 60);
                    var hour = Math.floor((lag / 3600) % 24);
                    var day = Math.floor((lag / 3600) / 24);
                    $(this).html('<span style="color:#910012;">&nbsp;'+day+'&nbsp;</span>'+'<?php echo $lang['bearshop_day'];?>'+'<span style="color:#910012;">&nbsp;'+hour+'&nbsp;</span>'+'<?php echo $lang['bearshop_hour'];?>'+'<span style="color:#910012;">&nbsp;'+minite+"&nbsp;</span>"+'<?php echo $lang['bearshop_minute'];?>'+'<span style="color:#910012;">&nbsp;'+second+'&nbsp;</span>');
                }else{
                    var aid = $(this).attr('aid');
                    var html = '<div class="saleEndBtn">'+$(this).attr('con')+'&nbsp;拍卖结束 </div>';
                    $('div[cur="'+aid+'"]').remove();
                    $('div[bidaid="'+aid+'"]').html(html);
                }
            });
            setTimeout(updateEndTime,1000);
        }
        setTimeout(updateEndTime,1000);
    });
</script>
<!--引入导航菜单与底部-->
<?php $zh_nav="首页";?>
<?php include template('home/zsm/nav');?>
